package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Person;
import com.google.gwt.event.shared.HasHandlers;

public class PersonDeletedEvent extends
		GwtEvent<PersonDeletedEvent.PersonDeletedHandler> {

	public static Type<PersonDeletedHandler> TYPE = new Type<PersonDeletedHandler>();
	private Person person;

	public interface PersonDeletedHandler extends EventHandler {
		void onPersonDeleted(PersonDeletedEvent event);
	}

	public PersonDeletedEvent(Person person) {
		this.person = person;
	}

	public Person getPerson() {
		return person;
	}

	@Override
	protected void dispatch(PersonDeletedHandler handler) {
		handler.onPersonDeleted(this);
	}

	@Override
	public Type<PersonDeletedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<PersonDeletedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Person person) {
		source.fireEvent(new PersonDeletedEvent(person));
	}
}
